package com.pzhu.record.service.impl;

import com.pzhu.record.entity.Achievement;
import com.pzhu.record.entity.Page;
import com.pzhu.record.service.AchievementService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Zhou YuSen
 * @date 2020/4/10 14:38
 */
@Service("achievementService")
public class AchievementServiceImpl extends BaseServiceImpl implements AchievementService {
    @Override
    public int insert(Achievement achievement) {
        return 0;
    }

    @Override
    public int update(Achievement achievement) {
        return 0;
    }

    @Override
    public int delete(String id) {
        return 0;
    }

    @Override
    public int deleteAll(String[] pks) {
        return 0;
    }

    @Override
    public Achievement selectById(String id) {
        return null;
    }

    @Override
    public List<Achievement> selectAll() {
        return null;
    }

    @Override
    public int insertSelective(Achievement achievement) {
        return 0;
    }

    @Override
    public int insertBatch(List<Achievement> achievementList) {
        int i = achievementMapper.insertBatch(achievementList);
        return i;
    }

    @Override
    public Page<Achievement> selectPage(int pageIndex, Achievement achievement) {
        Page<Achievement> page = new Page<Achievement>();
        page.setParamEntity(achievement);
        Integer pageNumber = selectPageCount(page);
        List<Achievement> list = new ArrayList<Achievement>();
        if (pageIndex < 1) {
            pageIndex = 1;
        }
        page.setPageIndex(pageIndex);
        page.setPageNumber(pageNumber);
        if (page.getPageNumber() % page.getPageSize() == 0) {
            page.setPageCount(page.getPageNumber() / page.getPageSize());
        } else {
            page.setPageCount(page.getPageNumber() / page.getPageSize() + 1);
        }
        list = achievementMapper.selectPageList(page);
        page.setList(list);
        return page;
    }

    @Override
    public Integer selectPageCount(Page<Achievement> bbsuserPage) {
        return achievementMapper.selectPageCount(bbsuserPage);
    }

    @Override
    public List<Achievement> selectExport(Map<String, String> keywords) {
        return achievementMapper.selectExport(keywords);
    }
}
